home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0292.ZIP / DSI-DCAT.ARC / DSIREAD.PRG < prev    next >
Text File  |  1985-12-21  |  5KB  |  204 lines

  1. DO WHIL .F.
  2.  
  3.   DSIREAD.PRG   (c) 1984  Darwin Systems, Inc.
  4.  
  5.   AUTHOR:       P.  L. Olympia, Ph.D.     -07/15/84-
  6.  
  7.   PURPOSE:      Program reads the directory of disk then 
  8.                 extracts the diskname, # of bytes free & used
  9.                 loads these info to DIRDISK.DBF. Then it extracts
  10.                 the file-specific data and load these into DIRFILE
  11.  
  12.                 Program is called by (and returns to) DSIdCAT.PRG
  13.  
  14. ENDDO whil .F.
  15.  
  16. PUBL mdisk,mdir,mdiskname,bell
  17. mdisk=TRIM(mdisk)
  18.  
  19. *              Read the disk directory
  20.  
  21. DO WHIL .T.
  22.  CLEAR
  23.  ? 'Mount disk in '+mdisk
  24.  WAIT 'Press X to eXit. Any other key to continue ..' TO x
  25.  IF x$'xX'
  26.     RETU
  27.  ENDIF
  28.  
  29. *        Start reading disk
  30.  nsubdir=0
  31.  root=.T.
  32.  subname=' '
  33.  
  34.  DO WHIL root .OR. nsubdir>0
  35.     
  36.     IF nsubdir>0
  37.        nsubc=STR(nsubdir,1)
  38.        subname=subname&nsubc
  39.        x=mdisk+'\'+subname
  40.        RUN CD &x
  41.     ENDIF nsubdir
  42.  
  43.     RUN DIR &mdisk.*.* >&mdir
  44.     ?
  45.     ? 'The disk directory is as follows:'
  46.     TYPE &mdir
  47.  
  48.     SELE 4
  49. *               Get rid of the old records
  50.     ZAP
  51. *               Append data
  52.     APPE FROM &mdir SDF
  53. *               Get the disk label
  54.     GO 2
  55.     mdiskname=SUBSTR(fill3,2,1)+fdate+fill4
  56. *        Does this disk have any label?
  57.     IF 'no label'$mdiskname
  58.        CLEA
  59.        ? bell+'This disk has no label'
  60.        TEXT
  61.  
  62.           C - Continue anyway
  63.           L - Label the disk (CLIP.COM assumed to be available)
  64.           A - Abort this. Read another disk
  65.  
  66.         ENDT
  67.         WAIT 'Pick a letter (C,L,A) ---> ' TO what
  68.         what=UPPER(what)
  69.  
  70.     DO CASE
  71.            CASE what='C'
  72.            CASE what='L'
  73.              CLEA
  74.          @ 10,0 SAY 'What should be the disk label?' GET mdiskname ;
  75.             PICT '!!!!!!!!!!!'
  76.              READ 
  77.          mdiskname=TRIM(mdiskname)    
  78. *            Place label on disk using CLIP.COM
  79.          RUN CLIP &mdisk.&mdiskname
  80.            OTHERWISE
  81.              EXIT
  82.          ENDC
  83.       ENDIF no label  
  84.       mdiskname=TRIM(mdiskname)
  85.  
  86.     IF nsubdir>0
  87.        mdiskname=TRIM(mdiskname+'\'+subname)
  88.     ENDIF nsubdir
  89.  
  90. *        Has this disk been cataloged before?
  91.     CLEA
  92.     ? 'Checking if disk '+mdiskname+' has been cataloged before ...'
  93.     SELE 2
  94.     SEEK mdiskname
  95.     IF .NOT. EOF()
  96.        ? bell+'Disk Name '+ mdiskname+ ' already exists in the catalog'
  97.        TEXT
  98.  
  99.           C - Continue anyway (previous catalog entries will be deleted)
  100.           A - Abort this. Read another disk
  101.  
  102.         ENDT
  103.         WAIT 'Pick a letter (C,A) ---> ' TO what
  104.         what=UPPER(what)
  105.  
  106.     DO CASE
  107.            CASE what='C'
  108.             ? 'Deleting current entries'
  109.             ?
  110.         SET TALK ON
  111.         DELE
  112.         PACK
  113.         SELE 1
  114.         DELE ALL FOR disk=mdiskname
  115.         PACK
  116.                 SET TALK OFF
  117.            OTHERWISE
  118.              EXIT
  119.          ENDC
  120.      ENDIF duplicate diskname
  121.              
  122.     SELE 4  
  123.     DELE
  124. *               Get subdirectory name & Delete all blank records
  125.     GO 3
  126.     DELE
  127.     DELE ALL FOR ftype='  ' .AND. fname=' '
  128.     DELE ALL FOR SUBSTR(fname,1,1)='.'
  129. *               Get # of files
  130.     GO BOTT
  131.     mnumfiles=VAL(SUBSTR(fname,5,4)+fill1)
  132.     mbytesf=VAL(SUBSTR(fbytes,5,2)+fill3+SUBSTR(fdate,1,4))
  133.     DELE
  134. *               Extract data to load to DSIFILE.DBF
  135.     SET FILTER TO .NOT. DELETED()
  136.     GO TOP
  137.     totbytes=0
  138.  
  139.     DO WHIL .NOT. EOF()
  140. *        Is this a subdirectory?
  141.        IF SUBSTR(fill2,2,2)='<D'
  142.           nsubdir=nsubdir+1
  143.           nsubc=STR(nsubdir,1)
  144.           x=fname
  145.           IF ftype # ' '
  146.              X=TRIM(x)+'.'+ftype
  147.           ENDIF ftype
  148.           subname&nsubc=x
  149.           SKIP
  150.           LOOP
  151.         ENDIF subdirectory
  152.  
  153. *        Is this file an excluded file?
  154.         mfile=TRIM(fname)
  155.         IF ftype # ' '
  156.            mfile=mfile+'.'+ftype
  157.         ENDIF ftype
  158.         ? 'Working on file ... '+mfile
  159. *        xclud=.F.
  160.         SELE 3
  161.         SEEK mfile
  162.         IF .NOT. EOF()
  163.            SELE 4
  164.            SKIP
  165.            LOOP
  166.         ENDIF not eof
  167.         SELE 4
  168.             
  169.        mfbytes=VAL(fbytes)
  170.        totbytes=totbytes+mfbytes
  171.     mfdate=CTOD(fdate)
  172.    
  173.     SELE 1
  174.         APPE BLAN
  175.        REPL file WITH mfile, fbytes WITH mfbytes, fdate WITH mfdate
  176.        REPL ftime WITH d->ftime, disk WITH mdiskname
  177.        SELE 4
  178.        SKIP
  179.     ENDDO whil not eof
  180.     SET FILT TO
  181.     SELE 2
  182.     APPE BLAN
  183.     REPL disk WITH mdiskname, numfiles WITH mnumfiles
  184.     REPL bytesfree WITH mbytesf, bytesused WITH totbytes
  185.  
  186.     SELE 4
  187.     IF root
  188.        root=.F.
  189.        totsub=nsubdir
  190. *        If there is no subdirectory set up for next disk
  191.        IF nsubdir > 0
  192.       nsubdir=1
  193.        ENDIF nsubdir
  194.     ELSE
  195.        nsubdir=nsubdir+1
  196.        IF nsubdir > totsub
  197.           nsubdir=0 
  198.        ENDIF nsubdir
  199.     ENDIF root
  200.  
  201.   ENDDO whil root or subdir
  202.   ENDDO WHIL t
  203. RETU
  204.